﻿<UserControl x:Class="Invoicing.NewWpf.UserControls.Report"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:app="clr-namespace:Invoicing.NewWpf"
        mc:Ignorable="d" 
        d:DesignHeight="300" d:DesignWidth="600"
	 >
    <UserControl.Resources>
        <app:BinaryImageConverter x:Key="imgConverter" />
    </UserControl.Resources>
        <StackPanel>
        <TextBlock Text="{Binding Seller.Name}"  Style="{StaticResource Heading2}"/>
        <StackPanel Orientation="Horizontal" >
            <TextBlock Text="{Binding Seller.Address}"/>
            <TextBlock Text =", "/>
            <TextBlock Text="{Binding Seller.PostalCode}"/>
        </StackPanel>
        <StackPanel Orientation="Horizontal" Margin="0,0,0,8">
            <TextBlock Text="{Binding Seller.City}"/>
            <TextBlock Text =", "/>
            <TextBlock Text="{Binding Seller.Country}"/>
        </StackPanel>
        <TextBlock Text="INVOICE"  Style="{StaticResource Heading1}" HorizontalAlignment="Center"/>
        <DockPanel Margin=" 0,0,0,8" >
            <StackPanel DockPanel.Dock="Right" Margin="0,0,0,8">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Row="0" Grid.Column="0" Text="Invoice # : " Style="{StaticResource Heading2}" HorizontalAlignment="Right"/>
                        <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Number}" Style="{StaticResource Heading2}"/>
                        <TextBlock Grid.Row="1" Grid.Column="0" Text="Date : " Style="{StaticResource Heading2}" HorizontalAlignment="Right"/>
                        <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Date, StringFormat='\{0:MMMM dd, yyyy\}'}"
                           Style="{StaticResource Heading2}"/>
                    </Grid>
            </StackPanel>
            <StackPanel DockPanel.Dock="Left">
            <StackPanel>
                <TextBlock Text="To: "/>
                <TextBlock Text="{Binding Client.Name}"  Style="{StaticResource Heading2}"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                <TextBlock Text="{Binding Client.Address}"/>
                <TextBlock Text =", "/>
                <TextBlock Text="{Binding Client.PostalCode}"/>
                <TextBlock Text =", "/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
            <TextBlock Text="{Binding Client.City}"/>
            <TextBlock Text =", "/>
            <TextBlock Text="{Binding Client.State}"/>
            <TextBlock Text =", "/>
            <TextBlock Text="{Binding Client.Country}"/>
        </StackPanel>
        </StackPanel>
        </DockPanel>
        <DockPanel Margin="0,0,0,8">
            <DataGrid ItemsSource="{Binding Details}"  
                      AutoGenerateColumns="False" 
                      IsReadOnly="True" 
                      DockPanel.Dock="Top" 
                      Foreground="Black"
                      ClipToBounds="True" 
                    
                      CanUserAddRows="False"
                      CanUserDeleteRows="False"
                      CanUserSortColumns="False" 
                      CanUserResizeRows="False" 
                      CanUserResizeColumns="False" 
                      CanUserReorderColumns="False" 
                       EnableRowVirtualization="False" Focusable="False" IsHitTestVisible="False" IsEnabled="False" >
                <!--<DataGrid.Resources>
                    <Style TargetType="{x:Type DataGridColumnHeader}">
                        <Setter Property="Background" Value="Silver" />
                        <Setter Property="FontWeight" Value="Bold"/>
                       
                        <Setter Property="BorderThickness" Value="1"/>
                        <Setter Property="BorderBrush" Value="Black"/>
                    </Style>
                    
                </DataGrid.Resources>-->
                <DataGrid.Columns>
                    <DataGridTextColumn Header="No." Binding="{Binding Index}"/>
                    <DataGridTextColumn Header="Description" Binding="{Binding Description}" Width="*">
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="TextBlock">
                                <Setter Property="TextWrapping" Value="Wrap"/>
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Unit Price (USD)" Binding="{Binding Price, StringFormat='${0:f2}'}">
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="{x:Type TextBlock}">
                                <Setter Property="HorizontalAlignment" Value="Right" />
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Quantity" Binding="{Binding Units}">
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="{x:Type TextBlock}">
                                <Setter Property="HorizontalAlignment" Value="Right" />
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Header="Amount (USD)" Binding="{Binding Value, StringFormat='${0:f2}'}" >
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="{x:Type TextBlock}">
                                <Setter Property="HorizontalAlignment" Value="Right" />
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                </DataGrid.Columns>
            </DataGrid>
           
        </DockPanel>
        <TextBlock Text ="{Binding TotalAmount,StringFormat='Total Invoice Amount (USD): ${0:f2}'}" HorizontalAlignment="Right" Style="{StaticResource Heading2}" Margin="0,0,10,8"/>
        <StackPanel Width="200" Margin="20,20,20,20" HorizontalAlignment="Left">
            <TextBlock Text="Authorized Signature"/>
            <Image Source="{Binding Seller.Signature,Converter={StaticResource imgConverter}}" Stretch="UniformToFill"  StretchDirection="Both"/>
            <Separator/>
        </StackPanel>
    </StackPanel>
</UserControl>
